<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");
	response.setCharacterEncoding("UTF-8");
	response.setContentType("text/html;charset=utf-8");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
	name="viewport" content="width=device-width,initial-scale=1" />
<link href="css/jquery.mobile-1.4.5.css" rel="Stylesheet"
	type="text/css" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.mobile-1.4.5.js" type="text/javascript"></script>
<%@ page import="com.wanhua.*"%>
<script>
	function showPopup(type) {//弹出层 
		alert(type);
	}
	function hidePopup(type) {//关闭层 
		//var objDiv = null;//objDiv是目标div 
		if (type == 'add') {
			objDiv = document.getElementById("popDivAdd");
		} else if (type = 'delete') {
			objDiv = document.getElementById("popDivDelete");
		}
		objDiv.style.visibility = "hidden";
	}
</script>
</head>
<body>
	<div data-role="page" data-add-back-btn="true">
		<div id="ptitle" data-role="header">
			<h1>连接数据库测试</h1>
		</div>
		<table id="imgList" border="0" align="center" cellspacing="10">
			<tr id="title">
				<td bgcolor="lightblue"><div align="center">
						<div align="left">user</div>
					</div></td>
				<td bgcolor="lightblue"><div align="center">
						<div align="left">process_priv</div>
					</div></td>
				<td bgcolor="lightblue"><div align="center">
						<div align="left">password_expired</div>
					</div></td>
			</tr>
		</table>
		<div id="dbinfo">
			<input type="text" id="idtest" name="id" value="0" />
			<button id="connectDB">获取数据库</button>
		</div>
	</div>

	<script type="text/javascript">
		$(document).ready(function() {
			$("#connectDB").click(function() {
				<%
				AppMine ap = new AppMine();
				UserList dbrresult = ap.getData();
				if(dbrresult.getUserResult().length() > 0){
					%>$("#idtest").val("<%=dbrresult%>");<%
				}else{
					%>$("#imgList tr:not(#title)").remove();<%
					for (UserEntity xx : dbrresult.getUserList()) {
						%>$("#imgList").append("<tr>"
							+ "<td><%=xx.getUser()%></td>"
	                        + "<td><%=xx.getProcessPriv()%></td>"
	                        + "<td><%=xx.getPasswordExpired()%></td>"
	                        + "</tr>");<%
			        }
				}
				%>
			});
		});
	</script>
</body>
</html>